package com.cta.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.cta.constant.DiscountType;

@Entity
@Table(name = "cta_discount_rate")
public class DiscountRate implements BaseEntity {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "cta_discount_rate_seq")
	@SequenceGenerator(name = "cta_discount_rate_seq", sequenceName = "cta_discount_rate_seq")
	@Column(name = "id", unique = true, nullable = false)
	private Long id;
	
	@Column(name = "type", nullable = false)
	@Enumerated(EnumType.STRING)
	private DiscountType type;
	
	@Column(name = "date_type")
	private String dateType;
	
	@Column(name = "condition", nullable = false, length = 1000)
	private String condition;
	
	@Column(name = "value",  length = 1000)
	private String value;
	
	@Column(name = "description")
	private String description;
	
	@Column(name = "tariff_id", nullable = true)
	private Long tariffId;
	
	@Column(name = "tariff_group_id", nullable = true)
	private Long tariffGroupId;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public DiscountType getType() {
		return type;
	}

	public void setType(DiscountType type) {
		this.type = type;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Long getTariffId() {
		return tariffId;
	}

	public void setTariffId(Long tariffId) {
		this.tariffId = tariffId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DiscountRate other = (DiscountRate) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (type != other.type)
			return false;
		return true;
	}

	public Long getTariffGroupId() {
		return tariffGroupId;
	}

	public void setTariffGroupId(Long tariffGroupId) {
		this.tariffGroupId = tariffGroupId;
	}

	public String getDateType() {
		return dateType;
	}

	public void setDateType(String dateType) {
		this.dateType = dateType;
	}

	
}
